During software development, developers spend considerable time reading their own code and reading code written by other developers. In fact, typically, developers spend more time reading code than actually writing code. When the developers write code, they typically define artifacts such as classes, attributes and methods using descriptive and readable names. These descriptive and readable names allow others, and themselves, to easily grasp the general idea of the code. For example, if the code is for an accounting program, a developer may conveniently name a class “Accounts Receivable.”
While these descriptive and readable names allow others to easily grasp the general idea of the code, the names are often so common that they conflict with other artifacts having identical names. Because no two artifacts in the same scope can have the same name, names must be chosen carefully so that the names do not collide.
One approach for having unique names is by prefixing the name of the artifact (class, type, interface, etc.) with a company name, a product name or the like. This approach, however, results in very lengthy and cumbersome names. These lengthy and cumbersome names make it more difficult to write code. In addition, when trademarks or domain names are used, the prefixes do not provide a stable reference over a long period of time because the trademark or domain name may expire, may be sold or may otherwise undergo a change of ownership.
Another approach for having unique names is to assign a globally unique identifier (GUID) to each object. One disadvantage with this approach is that the GUID is not an easily readable name for humans and does not easily convey the general idea for the object or code. In addition, a GUID is lengthy and cumbersome to write.
Another approach is to include object definitions within a flat namespace (e.g., # includes in C). However, this approach does not avoid clashes during run-time and relies on a build system to initially resolve the conflicting names.
Currently, these approaches fall short of a naming mechanism that conveniently prevents names from clashing during the build process and during runtime.